package com.example.administrator.zhongyichou.activity;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.administrator.zhongyichou.Bean.BaseEventBean;
import com.example.administrator.zhongyichou.base.BaseActivity;
import com.example.administrator.zhongyichou.config.Constants;
import com.example.administrator.zhongyichou.net.protocol.GsonBaseProtocol;
import com.example.administrator.zhongyichou.utils.ToastUtil;
import com.example.administrator.zhongyichou.net.core.HttpLoader;
import com.example.administrator.zhongyichou.view.HeaderView;
import com.example.administrator.zhongyichou.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by lichenyu on 2017/11/30.
 * 描述：
 */

public class AddBankCardOneActivity extends BaseActivity {
    @BindView(R.id.headerview)
    HeaderView headerview;
    @BindView(R.id.edit_real_name)
    EditText editRealName;
    @BindView(R.id.edit_card_id)
    EditText editCardId;
    @BindView(R.id.btn_next)
    Button btnNext;

    @Override
    protected void init() {
        ButterKnife.bind(this);
        initHead();
    }

    @Override
    protected void responseData(GsonBaseProtocol mGsonBaseProtocal) {
    }

    @Override
    protected HttpLoader initHttpLoader() {
        return null;
    }

    @Override
    protected int initContentView() {
        return R.layout.add_bankcard_activity;
    }

    @Override
    public boolean onEventBus(BaseEventBean baseEventBean) {
        if (baseEventBean.code == Constants.TYPE_3) {
            finish();
        }
        return false;
    }

    @OnClick(R.id.btn_next)
    public void onViewClicked() {
        String name = editRealName.getText().toString().trim();
        if (TextUtils.isEmpty(name)) {
            ToastUtil.showToast("请输入真实姓名");
            return;
        }
        String cardID = editCardId.getText().toString().trim();
        if (TextUtils.isEmpty(cardID)) {
            ToastUtil.showToast("请输入银行卡号");
            return;
        }
        Intent intent = new Intent(this, AddBankCardTwoActivity.class);
        intent.putExtra("name", name);
        intent.putExtra("cardID", cardID);
        startActivity(intent);

    }

    private void initHead() {
        headerview.setTitle("添加银行卡");
        headerview.bindOnclickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (v.getId()) {
                    case HeaderView.LEFT:
                        finish();
                        break;
                }
            }
        });
    }
}
